<h1 id="tnsnames-grammar">Tnsnames Grammar</h1>
<h2 id="summary">Summary</h2>
<p>An ANTLR4 grammar for Oracle 11g Release 2 <a href="http://docs.oracle.com/cd/E11882_01/network.112/e10835/tnsnames.htm" title="Oracle&#39;s tnsnames.ora specification document">tnsnames.ora</a> files.</p>
<p>This grammar is based on the details in the above document plus a few seemingly undocumented bits and pieces that I know are still valid but are not in the above document.</p>
<h2 id="missing-features">Missing Features</h2>
<p>This grammar has one missing feature, that I know about:</p>
<ul>
<li>The host names for the TCP protocol can be a DNS host name or an IP address. Only IPv4 is acceptable at present. I have yet to get my head around the format of an IPv6 address. (Sorry!)</li>
</ul>
<p>Hey, this is my first ever proper grammar, so it's not too bad!</p>
<h2 id="examples">Examples</h2>
<p>There is an example parser, in the examples directory, which allows you to parse a tnsnames.ora file looking for errors. It is looking for syntax and semantic errors only. It doesn't check that ports are in range, or that a correctly formatted IP address has been supplied etc.</p>
<p>It works on normal entries for databases and also those entries for listeners and scan listeners - at least, all the ones I've tried it out on.</p>
<p>There is a valid test file, tnsnames.test.ora, supplied if you want to have a play. You'll need to edit a few problems into this file because at the moment, it is valid.</p>
<p>If you want a full blown tnsnames checker that <em>does</em> do all that parsing and checking and reporting errors etc, you can find one <a href="http://qdosmsq.dunbar-it.co.uk/blog/2014/12/tnsnames-checker-utility/" title="Tnsnames checker utility on my blog">here</a> Source code is also available on <a href="https://github.com/NormanDunbar/Tnsnames_checker" title="Source code for full blown tnsnames parser utility">GitHub</a></p>
<p>Norman@dunbar-it.co.uk.</p>
